<div class="col-lg-12 thumbnail">
    <?= form_open("", array("class" => "col-xs-7 contact_form", "role" => "form", "id" => "signup-member")) ?>
        <div class="row lbl-header">
            <div class="col-md-3">
                <strong>Nama</strong>
            </div>
            <div class="col-md-9">
                <input class="form-control" placeholder="Nama Anda" name="nama" type="text" value="" required pattern="^([a-zA-Z]+(?:\.)?(?:(?:\'|\s)[a-zA-Z]+(?:\.)?)*){3,}$">
                <span class="form_hint">Isikan dengan nama lengkap Anda</span>
            </div>
        </div>
        <div class="row lbl-header">
            <div class="col-md-3">
                <strong>Nomor HP</strong>
            </div>
            <div class="col-md-9">
                <input class="form-control" placeholder="Nomor HP" name="nohp" type="text" maxlength="16" autofocus required pattern="\+?[0-9]{7,}">
                <span class="form_hint">Isikan dengan nomor handphone Anda</span>
            </div>
        </div>
        <div class="row lbl-header">
            <div class="col-md-3">
                <strong>Email</strong>
            </div>
            <div class="col-md-9">
                <input type="email" name="email" class="form-control" maxlength="64" required placeholder="Email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" />
                <span class="form_hint">Isikan dengan email yang valid, contoh: email@anda.com</span>
            </div>
        </div>
        <div class="row lbl-header">
            <div class="col-md-3">
                <strong>Captcha</strong>
            </div>
            <div class="col-md-9">
                <?=$this->m7captcha->createCaptcha()?>
                <input type="text" name="captcha" maxlength="6" required class="form-control" placeholder="Masukkan captcha di atas" style="margin-top:5px"/>
                <span class="form_hint">Masukkan karakter yang tertera dalam captcha</span>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <button style="margin: 20px 30px 20px 20px;" tabindex="8" class="btn btn-warning pull-left" type="reset" name="reset_form" id="reset"><i class="fa fa-refresh"></i> Reset</button>
                <button style="margin: 20px 25px 20px 0;" tabindex="7" class="btn btn-primary pull-right" type="button" name="submit_form" id="submit" value="Simpan" data-loading-text="Sedang diproses..."><i class="fa fa-users"></i> Request Pendaftaran</button>
            </div>
        </div>
    <?= form_close() ?>

    <div class="row" style="display: none;" id="confirmation">
        <div class="col-md-12">
            <div class="alert alert-success alert-dismissible" role="alert">
                <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <strong>Selamat,</strong> pendaftaran berhasil dilakukan.<br/>Silahkan lakukan aktifasi downline di menu <a href="<?=base_url("network/downline_activate")?>">aktifasi downline</a>
            </div>
        </div>
    </div>
</div>

<script>    
    $("#signup-member button#submit").on("click", function(){
        var inv = $("#signup-member input:invalid").length;

        if(inv == 0){
            var ajax = new AjaxPost("<?= base_url("signup") ?>");
            ajax.data = {
                nama        : $("#signup-member input[name=nama]").val(),
                nohp        : $("#signup-member input[name=nohp]").val(),
                email       : $("#signup-member input[name=email]").val(),
                captcha     : $("#signup-member input[name=captcha]").val(),
                referral    : '<?= $this->user->get_id() ?>' 
            };
            ajax.success = function(msg){
                var www = new Message(msg);
                if(www.error){
                    alert("Maaf pendaftaran gagal: \n"+www.result);
                } else {
                    $("#signup-member").hide();
                    $("#confirmation").show();
                    
                    $("#signup-member input:not([type=hidden])").val("");
                }
                
                if(typeof reload_captcha == "function"){
                    reload_captcha();
                }
            };
            ajax.doPost("#submit");
        } else {
            alert("Silahkan lengkapi data Anda dengan data yang valid");
        }
    });
</script>